<% content_for :title do %>Display all products<% end %>
<h1>All Comments by Product</h1>

<table class="table">
	<thead>
		<tr>
			<th>Product</th>
			<th>Comment Author</th>
			<th>Comment Content</th>
		</tr>
	</thead>

	<tbody>
			<tr>
		<% @products.each do |product| %>
				<td><%= product.name %></td>

				<% product.comments.each do |comment| %>
						<td><%= comment.author %></td>
						<td><%= comment.content %></td>
						<td><%= link_to 'Delete', product_comment_path(product.id, comment), method: :delete, data: { confirm: 'Are you sure?' } %></td>
					</tr>
					<tr>
					<td></td>
				<% end %>

			</tr>
		<% end %>
	</tbody>

</table>

<%= link_to "Back to Products Page", products_path %>